package com.my.collection.stack.v5;

/**
 * Created by ZhongGang
 * at 2018/7/26 14:18
 */
public class Lock {
    private boolean locked = false;

    public void lock() throws InterruptedException {
        synchronized (this) {
            if (this.locked) {
                this.wait();
            }

            this.locked = true;
        }
    }

    public void unlock() {
        synchronized (this) {
            this.locked = false;
            this.notify();
        }
    }
}
